package at.dl.android.dota.adviser;

import android.view.LayoutInflater;
import android.widget.Gallery;

public abstract class AbstractGalleryAdapter extends CallActivityImageAdapter {

    protected final Gallery gallery; 
    protected final LayoutInflater mInflater;

    AbstractGalleryAdapter ( Gallery gallery, 
                             ActivityWithDB currentAvticity, 
                             Class targetActivityClass, 
                             String keyParamName, 
                             int[] ids, 
                             String[] names ) {
        super(currentAvticity,targetActivityClass,keyParamName,ids,names);
        mInflater = LayoutInflater.from(context);
        this.gallery = gallery;
    }

    public void adjustSelection () {
        int cnt = 0;
        for ( ; cnt < names.length && names[cnt] != null; cnt++ );
        if ( cnt == 1 )
            gallery.setSelection(0,true);
        else if ( cnt > 1 )
            gallery.setSelection(1,true);
    }
}
